package org.base.common.mybatis.handler;

import org.apache.ibatis.type.JdbcType;
import org.base.common.util.I18nUtils;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @author He mingliang
 */
public class LocalDateTypeHandler extends org.apache.ibatis.type.LocalDateTypeHandler {

    @Override
    public void setNonNullParameter(PreparedStatement ps, int i, LocalDate parameter, JdbcType jdbcType) throws SQLException {
        // 日期国际化处理
        final LocalDateTime i18nLocalDate = I18nUtils.i18nLocalDate((LocalDate) parameter);
        ps.setObject(i, i18nLocalDate);
    }
}
